package com.xtkj.superclub_shop.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xtkj.superclub_entity.entity.shop.Address;
import com.xtkj.superclub_shop.dao.IAddressDao;
import com.xtkj.superclub_shop.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lizheqi
 * @create 2019-12-30-16:30
 */
@Service
public class AddressServiceImpl implements IAddressService {
    @Autowired
    private IAddressDao addressDao;

    @Override
    public void addAddress(Address address) {
        System.out.println(address);
        addressDao.insert(address);
    }

    @Override
    public void updateAddress(Address address) {
        addressDao.updateById(address);
    }

    @Override
    public void delAddress(Address address) {
        addressDao.deleteById(address.getAddressId());
    }

    @Override
    public List<Address> listAddress(String userId) {
        //查询该用户的所有地址
        QueryWrapper<Address> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id",userId);
        List<Address> addresses = addressDao.selectList(wrapper);
        return addresses;
    }
}
